package top.lingkang.privatespace.dto;

import lombok.Data;

import java.io.Serializable;

/**
 * @author lingkang
 * Created by 2022/2/15
 */
@Data
public class ResponseResult<T> implements Serializable {
    private static final long serialVersionUID = 1L;
    private int code = 0;
    private String msg;
    private T data;

    public ResponseResult() {
    }

    public ResponseResult success(String msg) {
        this.msg = msg;
        return this;
    }

    public ResponseResult success(T data) {
        this.data = data;
        return this;
    }

    public ResponseResult success(String msg, T data) {
        this.data = data;
        return success(msg);
    }

    public ResponseResult fail(String msg) {
        this.msg=msg;
        code = 1;
        return this;
    }

    public ResponseResult fail(String msg, T data) {
        this.data = data;
        return fail(msg);
    }

    public ResponseResult(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public ResponseResult(int code, T data) {
        this.code = code;
        this.data = data;
    }

    public ResponseResult(int code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }
}
